package org.java.search.web;

import org.java.common.vo.ResultVo;
import org.java.item.entity.Sku;
import org.java.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author WHQ
 * @version 1.0
 * @date 2022-3-8 0008 下午 3:54
 */
@RestController
public class SearchController {
    @Autowired
    private SearchService searchService;

    /**
     * 访问地址:http://api.shopping.com/es/search/{title}
     * @param title
     * @return
     */
    @GetMapping("/search/{title}")
    public ResponseEntity<ResultVo<Sku>> search(@PathVariable("title")
                                                            String title
                                                ,Integer page,Integer limit) throws Exception {
        System.out.println("进入搜索服务的控制器"+title);
        ResultVo<Sku> vo = searchService.search(title,page,limit);
        return ResponseEntity.ok(vo);
    }
}
